/*
 * Acc_Mag.c
 *
 * Created: 17-03-2012 10:47:05
 *  Author: Unithra
 */ 

#include <avr/io.h>
#include "inc\TWI_Master.h"
#include "inc\ACC_Interface.h"
#include "inc\Uart.h"

/* Prototypes */



int main(void)
{
	int d = 0;
	char RcvByte = 0;
	InitUART(9600);                     // UART init with 9600 baud rate
	TWI_init_master();                  // TWI init with 100khz
	
	/* wait for a character from uart*/
	char ch = ReceiveByte();
	TransmitByte(ch);
    while(1)
    {
	    RcvByte = ReadByte(ACC_ADD,CTRL_REG1_A);
	    TransmitByte(RcvByte);
	    unsigned char i = 0;
		i = RcvByte/100;
		TransmitByte(i+48);
		i = RcvByte%100;	
		i = i/10;
		TransmitByte(i+48);
		i = RcvByte%10;
		TransmitByte(i+48);
		
	    TWI_Reset();
	   for(d=0;d<10000;d++);   
	   for(d=0;d<10000;d++);
    }
}